﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Basics</title>
</head>
<body>
    <script type="text/javascript">
        var basics = {
            numbers: {
                decimal: 10.0 == 10, //decimal notation
                exponential: 100 == 1e2, //exponent notation
                notAnumber: isNaN(NaN), //NaN represents a value that is not a number and can be detected only with isNaN function
                inf: Infinity, //largest number
            },
            strings: {
                aString: 'hi',
                anotherString: "hi again", //all chars are 2 bytes lenght
                numericalCode: "A" === "\u0041", // \u let's you specify numerically code
                equivalentStrings: 'c' + 'a' + 't' === 'cat',
            },
            varInsideFunctionMakeItPrivateToTheFunction: function () {
                //var inside function defines private variables
                var testFunction = function () {
                    var hidddenVariable;
                };
                return typeof hidddenVariable == 'undefined';
            }(),
            blocksDontCreateNewScope: function () {
                {
                    var visibleVariable = 1;
                }
                return typeof visibleVariable != 'undefined';
            }(),
            falsyValues: null || undefined || '' || 0 || NaN || false,
            //trulyValues is down
            forIn: function () {
                var testObj = { id: 1 }
                var ownProperties = 0;
                for (var item in testObj) {
                    if (testObj.hasOwnProperty(item)) {
                        ownProperties++;
                    }
                }
                return ownProperties == 1;
            }(),
            deleteOperator: function () {
                //delete a property
                var testObj = { id: 1 }
                var ok = testObj.id != undefined;
                delete testObj.id;
                return ok && testObj.id == undefined;
            }() && function () {
                //delete an array element
                var p = new Array('1');
                var ok = p[0] != undefined;
                delete p[0];
                return ok && p[0] == undefined;
            }(),
        };
        basics.__proto__.trulyValues = !basics.falsyValues && 'false' && {} && true;
    </script>
</body>
</html>
